package acwing._2LanQiao._11No11;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._2LanQiao._11No11
 * @File : Q2068.java
 * @Author : WangRuoyu
 * @Date 2023/3/27 22:03
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q2068 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        int k = Integer.parseInt(words[1]);
        long[][] hash = new long[11][k];
        long[] d = new long[n];

        words = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            long x = Long.parseLong(words[i]);
            d[i] = x;
            x = x % k;
            for (int j = 0; j < 11; j++) {
                hash[j][(int) x]++;
                x = x * 10 % k;
            }
        }

        long res = 0;
        for (long x : d) {
            int len = String.valueOf(x).length();
            int c = (int) (k - x % k) % k;
            res += hash[len][c];

            long t = x % k;
            for (int j = 0; j < len; j++) {
                t = t * 10 % k;
            }
            if (t == c) {
                res--;
            }
        }
        System.out.println(res);
    }
}
